package com.roger.springcloudGreenwich.api;

import com.roger.springcloudGreenwich.bean.BlockInfoItem;
import com.roger.springcloudGreenwich.service.BlockInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;

/**
 * Created by admin on 2020/3/13.
 */
@RestController
public class BlockInfoController {
    @Autowired
    private BlockInfoService blockInfoService;

    @RequestMapping(name = "/addBlock", method = RequestMethod.POST)
    public String addBlock(@RequestBody BlockInfoItem blockInfoItem){
        String id = UUID.randomUUID().toString();
        blockInfoItem.setId(id);
        blockInfoService.save(blockInfoItem);
        return "success";
    }

    @PostMapping("/findBlock")
    public Object findBlock(@RequestBody BlockInfoItem blockInfoItem){
        Object obj = blockInfoService.findByName(blockInfoItem.getBlockName());
        return obj;
    }
}
